package cn.stronglink.oil.utils;

import android.util.Log;

import com.google.gson.Gson;
import com.loopj.android.http.TextHttpResponseHandler;

import org.junit.Before;
import org.junit.Test;

import java.util.List;

import cn.stronglink.oil.entity.CommonResult;
import cn.stronglink.oil.entity.GasHistoryInfo;
import cz.msebera.android.httpclient.Header;

/**
 * Created by Tgb on 2017/10/18.
 */
public class HttpRequestTest {
    Gson gson = new Gson();
    @Before
    public void setUp() throws Exception {

    }

    @Test
    public void getGasHistoryList() throws Exception {
        HttpClientUtils.getGasHistoryList("/GPVLG22/CN1296661B0010/", 1, 10, new TextHttpResponseHandler() {
            @Override
            public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {

            }

            @Override
            public void onSuccess(int statusCode, Header[] headers, String responseString) {
                if (statusCode==200&&responseString!=null&&!responseString.isEmpty()){
                    Log.i("sssss",responseString);
                    CommonResult<List<GasHistoryInfo>> commonResult= new CommonResult();
                    commonResult = gson.fromJson(responseString,new com.google.gson.reflect.TypeToken<CommonResult<List<GasHistoryInfo>>>(){}.getType());
                    if (commonResult.getErrorMessage()==null&&commonResult.isSuccess()){
                        for (int i=0;i<commonResult.getData().size();i++) {
//                            Log.i("result",commonResult.getData().get(i).getGasName()+"\n");
                        }
                    }
                }
            }
        });
    }

}